package com.moli.iov.handle.worker.his.lmax;

import org.springframework.beans.factory.InitializingBean;

import java.util.concurrent.ConcurrentMap;

/**
 * Batch thread pool handle for disruptor.
 *
 * @param <T>
 * @param <R>
 *
 * @author OAK
 * @since 2020/01/16 16:46 PM.
 * @version 3.0.1
 * @see InitializingBean
 *
 */
public interface Disruptor<T extends ConcurrentMap, R extends DisruptorTask> extends InitializingBean {

    /**
     * According <R> Disruptor task to Initializing every one of disruptor batch thread pool.
     * @param task <R> Disruptor task.
     * @return Disruptor batch thread pool.
     */
    Disruptor<T, R> disruptor(R task);

    /**
     * Publish disruptor batch thread pool current group of <T> commit to data.
     * @param group Current group.
     * @param data <T> Commit to data.
     * @throws InterruptedException Interrupted exception @link{InterruptedException}.
     */
    void publish(String group, T data) throws InterruptedException;

    /**
     * Shut down processing of disruptor batch thread pool group.
     */
    void shutdown();

    /**
     * Get coroutine of summary size.
     * @return a coroutine of summary size.
     */
    int getCoroutineSize();

}